import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey =
    'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAN+nSrjuMm/DchGGitogqwF8tROOvRe0\n' +
    'bckXPHXZWCQWa86m1c1RgSbONk0gzJTPOsTIg0hMZP7BzOMXXvbq+ukCAwEAAQ=='
const privateKey =
    'MIIBVwIBADANBgkqhkiG9w0BAQEFAASCAUEwggE9AgEAAkEA36dKuO4yb8NyEYaK\n' +
    '2iCrAXy1E469F7RtyRc8ddlYJBZrzqbVzVGBJs42TSDMlM86xMiDSExk/sHM4xde\n' +
    '9ur66QIDAQABAkEAuDCZTEX3Sa4HgkFwlwWyb84ZfpreReh1RdgaFeBCQ6ydNwy6\n' +
    'LMbl1Gk1GbYvVHfw8z2FfItGV79jZVBib46I5QIhAPQGd1WhmRjfORTL6QnZ8TSR\n' +
    'LhIgqMUlS+ounOg+FUBPAiEA6qDoeeq+fWih4y4+xVJC6u/zNe1iqJYOsZih8lUh\n' +
    'S0cCIQCk9B4Ez4jbDEHcsf4kf6OSIjVfYZ5ULeMEOWAtiZH59wIhAJ8Cg+s0MvsM\n' +
    '8UHksnfKAz3zdnGius0kPTsRBRgVp6W7AiEAtMvduqmuF97F11OxAuBJSOXg9N9H\n' +
    '2RPR5KHo4hbYld8='

// 加密
export function encrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPrivateKey(privateKey) // 设置私钥
    return encryptor.decrypt(txt) // 对数据进行解密
}